<template>
	<div>
		<el-pagination
			background
			:current-page="pageIndex"
			:page-sizes="pageSizes"
			:page-size="pageSize"
			:layout="location === 'dialog' ? 'total, prev, pager, next' : 'total, sizes, prev, pager, next, jumper'"
			:total="total"
			@size-change="onPageSizeChange"
			@current-change="onPageChangeChange"
		/>
	</div>
</template>
<script>
    import { pageConfig } from '../../../utils/jk/jk-tool';

    export default {
        name: 'JkPage',
        props: {
            location: {
                type: String,
                default: '' // 在弹窗内为dialog;
            },
            layout: {
                type: String,
                default: 'total, sizes, prev, pager, next, jumper'
            },
            pageSize: {
                type: Number,
                default: pageConfig.pageSize
            },
            pageSizes: {
                type: Array,
                default() {
                    return pageConfig.pageSizes;
                }
            },
            total: {
                type: Number,
                default: 0
            },
            pageIndex: {
                type: Number,
                default: 1
            }
        },
        data() {
            return {
                name: ''
            };
        },
        methods: {
            onPageChangeChange(e) {
                this.$emit('on-change', e, this.pageSize);
            },
            onPageSizeChange(e) {
                this.$emit('on-change', 1, e);
                this.$emit('on-size-change', e);
            }
        }

    };
</script>
